//
//  BaseViewController.m
//  EraPig
//
//  Created by Mac_Mini on 2021/1/7.
//

#import "BaseViewController.h"
#import "UINavigationItem+MMAdd.h"
#import <SVProgressHUD/SVProgressHUD.h>
@interface BaseViewController ()

@end

@implementation BaseViewController
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (void)dealloc{
    [kNotificationCenter removeObserver:self name:LOGIN_SUCCESSED_NOTIFICATION object:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [GlobalFile backgroundColor];
    [self.navigationItem setBackBarButtonItemTitle:@""];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [kNotificationCenter addObserver:self selector:@selector(loginSuccessedNotification:) name:LOGIN_SUCCESSED_NOTIFICATION object:nil];
}
#pragma mark - --------------事件响应--------------
- (void)loginSuccessedNotification:(NSNotification *)notification{
    
}
#pragma mark - --------------代理方法--------------
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
#pragma mark - --------------自定义方法--------------
/// 弹出UIAlertController弹窗
/// @param title 弹窗辩题
/// @param message 弹窗描述
/// @param cancelBlock 取消
/// @param confirmBlock 确认
- (void)showAlertWithTitle:(NSString *)title
                   message:(NSString *)message
               cancelBlock:(void(^)(void))cancelBlock
              confirmBlock:(void(^)(void))confirmBlock{
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    [alertVC addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        if (cancelBlock) {
            cancelBlock();
        }
    }]];
    [alertVC addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (confirmBlock) {
            confirmBlock();
        }
    }]];
    [self presentViewController:alertVC animated:YES completion:nil];
}
/// 弹出UIAlertController弹窗
/// @param title 弹窗辩题
/// @param message 弹窗描述
/// @param confirmBlock 确认
- (void)showAlertWithTitle:(NSString *)title
                   message:(NSString *)message
              confirmBlock:(void(^)(void))confirmBlock{
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    [alertVC addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (confirmBlock) {
            confirmBlock();
        }
    }]];
    [self presentViewController:alertVC animated:YES completion:nil];
}
- (void)showWaitHUD{
    [SVProgressHUD showWithStatus:@"请稍等..."];
}
- (void)showWithMsg:(NSString *)msg{
    [SVProgressHUD showWithStatus:msg];
}
- (void)showSuccessWithMsg:(NSString *)msg{
    [SVProgressHUD showSuccessWithStatus:msg];
}
- (void)showErrorWithMsg:(NSString *)msg{
    [SVProgressHUD showErrorWithStatus:msg];
}
- (void)hideWaitHUD{
    [SVProgressHUD dismiss];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
